package cn.b.sky.modeler.controller;

import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.base.Throwables;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.TypeMismatchException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import java.util.Set;

@ControllerAdvice
@Slf4j
public class ControllerErrorHandler {


    // controller抛出未知异常全局捕获
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public void processControllerError(Exception ex, HttpServletResponse response) {
        log.error("[ControllerErrorHandler系统错误], errorStack: {}", Throwables.getStackTraceAsString(ex));
    }

}
